//
// Created by ChenJi on 2022/1/6.
//

#ifndef HC_AIRSENSOR_GENERALUSERCONTROLLER_H
#define HC_AIRSENSOR_GENERALUSERCONTROLLER_H
#include "main.h"
void HC_General_User_Controller_Init();
void HC_SetBeep(uint16_t time);
void button_init();
void handleButtons();
struct ButtonHandler {
    uint8_t buttonid;
    uint16_t button_reg;
    uint16_t button_time_limit;
    uint8_t button_long_press_mode;
    uint8_t button_listen_enable;
    uint8_t button_cycle_listen;
    GPIO_PinState button_isPressed;
    GPIO_PinState button_latest_state;
    uint8_t button_start_mode;
    uint8_t button_in_long_press_mode;
    uint8_t button_hold_callback_enable;
    uint8_t button_hold_callback_reg;
    uint8_t button_hold_callback_cycle;
};

void handleButtonTick(struct ButtonHandler *handle);
void initButton(struct ButtonHandler *handle);
void onPressDownCallback(struct ButtonHandler *handle);
void onFreeCallback(struct ButtonHandler *handle);
void onTimeReachCallback(struct ButtonHandler *handle);
void onHoldCycleCallback(struct ButtonHandler *handle);
void registerButton(uint8_t buttonid, uint16_t time, uint8_t mode, uint8_t cyclelisten, uint8_t hold_callback);
__weak void onButton0PressDown();
__weak void onButton0Free();
__weak void onButton0TimeReach();
__weak void onButton0HoldCycle();

#endif //HC_AIRSENSOR_GENERALUSERCONTROLLER_H
